feat: add yield statement and expression support#39
Open
dfl wants to merge 5 commits intotype-ruby:mainfrom
Open
feat: add yield statement and expression support#39dfl wants to merge 5 commits intotype-ruby:mainfrom
dfl wants to merge 5 commits intotype-ruby:mainfrom
Conversation
- Add IR::Yield node class with arguments attribute - Implement parse_yield in StatementParser - Add visit_yield in CodeGenerator for Ruby output - Support yield with/without arguments, modifiers Closes type-ruby#34 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add yield parsing in ExpressionParser for `result = yield(x)` pattern - Support parenthesized arguments in expression context - Add expression parser and E2E tests Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Extend check_yield_arguments to verify types match block signature
- Infer yield argument types using ASTTypeInferrer
- Create method type environment with parameter types
- Report type mismatch errors with expected vs actual types
Example error:
def each(&block: Proc(Integer) -> void)
yield "hello" # Error: expected 'Integer' but got 'String'
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Contributor
|
@dfl Thank you for your pull request! Before merging, I’d like to discuss a few things regarding this great new implementation. Let’s continue our conversation in the Discussions section while keeping this PR thread as is. Discussion #41 on going. |
Contributor
|
@dfl I just enabled CI workflow. Please check CI broken. |
- Add check_yield_arguments calls in check_types method - Add parse_block_parameter method for &block: Proc(T) -> R syntax - Add optional attribute to IR::Parameter for &block? syntax - Add callable_kind attribute to IR::FunctionType for Proc/Lambda - Add Proc(T) -> R and Lambda(T) -> R type syntax parsing - Fix RuboCop empty line issue
Contributor
Test Failure Fix AppliedI've pushed a fix for the failing tests to the Changes:
Test Results:@dfl Please cherry-pick commit 8e038f6 or merge from |
# Conflicts: # Gemfile.lock # lib/t_ruby/ir.rb # lib/t_ruby/parser_combinator/type_parser.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Test plan
🤖 Generated with Claude Code